<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>牧心农业</title>
    <link rel="stylesheet" type="text/css" href="/static/css/eui.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/mobile.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/iconfont.css" />
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/swipe.js"></script>
    <script src="/static/js/doT.min.js"></script>
    <script src="/static/js/func.js"></script>
</head>
<body>
    <div class="content margin_top_foot">
        <header class="header fixed_top bg_mx_green"></header>
        <div class="swipe">
            <div class='swipe-wrap'></div>
            <ul class="position"></ul>
        </div>
        <div class="detail"></div>
        <footer class="fixed_bottom flex_justify padding_h_15 border_t_mx bg_white detail_foot">
            <div class="relative iconfont icon-cart font_20 text_center detail_cart" onclick="location.href='<{url route='/shop/cart/index'}>'">
                <div class="badge total detail_total">1</div>
            </div>
            <div class="flex">
                <div class="btn btn_warning detail_addcart" onclick="cart()">加入购物车</div>
                <div class="btn btn_danger gobuy" onclick="gobuy()">立即购买</div>
            </div>
        </footer>
    </div>
    <!-- 轮播模版 -->
    <script type="text/template" charset="utf-8" id='swipe_template'></script>
    <!-- 详情模版 -->
    <script type="text/template" charset="utf-8" id='detail_template'>
        <div class="bg_white padding_10_15 border_b">
            <div class="font_16">{{=it.title}}</div>
            <div class="text_info">{{=it.text}}</div>
            <div class="flex_justify">
                <div class="warning font_18 lineheight_2">￥{{=it.price}}元</div>
                <{if empty($pigid) }>
                <div class="label_mx_green padding_h_5 font_12 circle_5" onclick="location.href='<{url route='/shop/site/from' pigid=$pigno}>'">源头追溯</div>
                <{/if}>
            </div>
        </div>
        <div class="bg_white padding_10_15 flex_justify margin_b_10">
            <div class="font_18">购买数量</div>
            <div class="border flex text_center lineheight_3">
                <div class="padding_h_5 bg_grey padding_h_10" onclick="change_num(-1)"><i class="iconfont icon-del"></i></div>
                <div class="border_l padding_h_5 text_center padding_h_15 number">1</div>
                <div class="border_l padding_h_5 bg_grey padding_h_10" onclick="change_num(1)"><i class="iconfont icon-add"></i></div>
            </div>
        </div>
        <div class="bg_white padding_10_15 margin_b_10">{{=it.article}}</div>
        <div class="bg_white">
            <div class="mx_green lineheight_3 border_b padding_h_15"><i class="iconfont icon-xiaoxixuanzhong01 font_20"></i> 顾客评论</div>
            <div class="padding_h_15 border_b">
                {{for(var i=0;i<it.comment.length;i++){}}
                <div class="comment light border_b padding_v_10">
                    <div class="flex_justify margin_b_10">
                        <div class="flex">
                            <div class="width_20">
                                <img class="circle" src="{{=it.comment[i].headimg}}" alt="">
                            </div>
                            <div class="padding_l_10 width_50 text_ellipsis">{{=it.comment[i].name}}</div>
                        </div>
                        <div class="font_16 width_100 grey">
                            {{for(var j=0;j<it.comment[i].star;j++){}}
                                <i class="iconfont icon-star1 warning"></i>
                            {{}}}
                        </div>
                        <div class="font_12 text_ellipsis">{{=it.comment[i].time}}</div>
                    </div>
                    {{if(it.comment[i].picture){}}
                    <div class="flex_row_3 margin_b_10">
                        {{for(var j=0;j<it.comment[i].picture.length;j++){}}
                            <div class="row_one"><img src="{{=it.comment[i].picture[j]}}" alt=""></div>
                        {{}}}
                    </div>
                    {{}}}
                    <div class="">{{=it.comment[i].content}}</div>
                </div>
                {{}}}
            </div>
        </div>
    </script>
    <script>
        // 页面初始化
            var banner = <{$banner}>;
            loadswipe(banner)
            var detail = <{$detail}>;console.log(detail)
            var evaldetail = doT.template($("#detail_template").text());
            loaddata(".detail",evaldetail,detail)
            loadheadbar("商品详情");
        // 购物车初始化及操作函数
            var mycarts = get_data("cart")||{},total = 1;
            if(mycarts.total){
                $(".total").html(mycarts.total);
            }else{
                $(".total").hide();
            }
            function change_num(i){
                total += i;
                total = total<1?1:total;
                $(".number").html(total);
            }
            function cart(){
                addcart(total,{id:detail.id,img:detail.img,o_price:detail.o_price,price:detail.price,title:detail.title,weight:detail.weight})
            }
            function gobuy(){
                set_data({id:detail.id,img:detail.img,o_price:detail.o_price,price:detail.price,title:detail.title,weight:detail.weight,num:total,selected:true},"buy")
                location.href ='/shop/order/confirm?type=gobuy';
            }
    </script>
</body>
</html>
